﻿using System;

namespace HtmlParser.Html
{
    public abstract class GeneralHtmlParser : IHtmlParser
    {
        /// <summary>
        /// 调用方法。
        /// </summary>
        /// <typeparam name="TResult">返回值类型。</typeparam>
        /// <param name="action">委托执行。</param>
        /// <returns>Returns the result.</returns>
        protected static TResult Execute<TResult>(Func<TResult> action)
        {
            TResult result = default(TResult);

            try
            {
                result = action();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }

            return result;
        }

        /// <summary>
        /// 调用方法。
        /// </summary>
        /// <param name="action">委托执行。</param>
        protected static void Execute(Action action)
        {
            Execute(() =>
            {
                action();
                return (object)null;
            });
        }

        public virtual HtmlElement[] Parse(string[] html)
        {
            throw new NotImplementedException();
        }

        public virtual HtmlElement[] Parse(string html)
        {
            throw new NotImplementedException();
        }

        public virtual HtmlElement[] Parse(char[] htmls)
        {
            throw new NotImplementedException();
        }
    }// end for class
}
